package com.coreJava.xianchengchi;

import java.util.concurrent.*;

/**
 * 作者: LCG
 * 日期: 2020/2/10 20:56
 * 描述:
 */
public class TestXianChengChi {
    public static void main(String[] args) {
        //工作队列
        ArrayBlockingQueue<Runnable> arrayBlockingQueue = new ArrayBlockingQueue<>(3);
        //线程池
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(
                2,//核心线程数
                2,//最大线程数
                50,//线程的存活时间
                TimeUnit.SECONDS,//线程的存活时间单位
                arrayBlockingQueue //工作队列
                );

        for (int i=0;i<5;i++){
            FutureTask<String> futureTask=new FutureTask<String>(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    System.out.println("=================="+Thread.currentThread().getName());
                    Thread.sleep(5000);
                    return "88888888";
                }
            });
            threadPoolExecutor.execute(futureTask);
        }




    }
}
